﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Admin_updateZhanhui : System.Web.UI.Page
{

    AccessDAO dao = new AccessDAO();
    protected void Page_Load(object sender, EventArgs e)
    {
        IsAdmin.Admin();
        this.btnSubmit.Attributes.Add("onclick", "javascript:showmessagebox();");
        if (!Page.IsPostBack)
        {
            int typeid = Convert.ToInt32(Session["zhId"].ToString());
            string sql = "select * from zhanhuiInfo where typeid=" + typeid;
            DataSet ds = dao.getDs(sql);
            foreach (DataRow dr in ds.Tables["message"].Rows)
            {
                this.drpType.Items.Add(dr["typeName"].ToString());
            }

            int id = Convert.ToInt32(Session["zhMessId"].ToString());
            string sql1 = "select * from zhanhui where id=" + id;
            DataSet ds1 = dao.getDs(sql1);
            foreach (DataRow dr in ds1.Tables["message"].Rows)
            {
                this.txtTitle.Text = dr["title"].ToString();
                this.DateTimePicker1.Text = dr["zhtime"].ToString();
                this.FCKeditor1.Value = dr["content"].ToString();
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Session["zhMessId"].ToString());
        string name = this.txtTitle.Text;
        DateTime tt = Convert.ToDateTime(this.DateTimePicker1.Text.ToString());
        string time = tt.ToShortDateString();

        string content = this.FCKeditor1.Value;

        string sql1 = "update zhanhui set title='" + name + "',zhtime='" + time + "',content='" + content + "' where id=" + id;

            if (dao.getComm(sql1) != 0)
            {
                RegisterStartupScript("check", "<script language='javascript'>alert('更新成功');</script>");

                Server.Transfer("zhanhuiMessage1.aspx");
            }
            else
            {
                RegisterStartupScript("check", "<script language='javascript'>alert('更新失败');</script>");
            }

        
    }
    //取消
    protected void Button1_Click(object sender, EventArgs e)
    {
        Server.Transfer("zhanhuiMessage1.aspx");
    }
}
